﻿using Store.Dal;
using Store.Model.Models;
using Store.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Store.Bll
{
    public class CommunityBll
    {
        //实例化dal
        private readonly CommodityDAL dal;
        public CommunityBll(CommodityDAL _dal)
        {
            dal = _dal;
        }


        /// <summary>
        /// 查询 显示
        /// </summary>
        /// <param name="sort"></param>
        /// <param name="state"></param>
        /// <param name="name"></param>
        /// <param name="brand"></param>
        /// <param name="page"></param>
        /// <param name="limit"></param>
        /// <param name="total"></param>
        /// <returns></returns>
        public List<CommunityModel> GetCommodityList(int sort, int state, string name, string brand, int page, int limit, out int total)
        {
            var data = dal.GetCommodityList(sort,state,name,brand,page,limit,out total);
            return data;
        }

        /// <summary>
        /// 查看商品信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public List<Commodity> GetCommodity(int id)
        {
            return dal.GetCommodity(id);
        }

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="commodity"></param>
        /// <returns></returns>
        public int CommodityAdd(Commodity commodity)
        {
            return dal.CommodityAdd(commodity);
        }


        /// <summary>
        /// 修改商品信息
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public int UpdCommodity(Commodity c)
        {
            return dal.UpdCommodity(c);
        }


        /// <summary>
        /// 修改商品状态
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public int UpdComState(Commodity c)
        {
            return dal.UpdComState(c);
        }



        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sid"></param>
        /// <returns></returns>
        public int CommodityDel(int sid)
        {
            return dal.CommodityDel(sid);
        }
        /// <summary>
        /// 批删
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public int CommodityDelList(string[] ids)
        {
            return dal.CommodityDelList(ids);
        }
        /// <summary>
        /// 绑定品牌下拉框
        /// </summary>
        /// <returns></returns>
        public IQueryable<Commodity> GetCommunityTypes()
        {
            return (IQueryable<Commodity>)dal.GetCommunityTypes();
        }

    }
}
